package com.duomn.mybatis.plugins.config;

import java.util.ArrayList;
import java.util.List;

public class Rule implements Cloneable, Propable {
	
	private String id;
	
	private String type;
	
	private String exp;
	
	private List<KV> props;
	
	private String column;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getExp() {
		return exp;
	}

	public void setExp(String exp) {
		this.exp = exp;
	}

	public List<KV> getProps() {
		return props;
	}

	public void setProps(List<KV> props) {
		this.props = props;
	}
	
	public void addProp(String key, Object obj) {
		if (props == null) {
			props = new ArrayList<KV>();
		}
		props.add(new KV(key, obj));
	}

	public String getColumn() {
		return column;
	}

	public void setColumn(String column) {
		this.column = column;
	}
	
	
	public Rule clone() {
		try {
			Rule rule = (Rule) super.clone();
			rule.setProps(null);
			return rule;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public String toString() {
		return "[id:" + id + ",type:" + type + ",exp:" + exp + ",column:" + column + ", kvs:" + props.toString() +  "].";
	}
}
